package com.ruoyi.eam.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.eam.doman.EamManageD;
import com.ruoyi.eam.service.IEamManageDService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 资产记录从Controller
 * 
 * @author ruoyi
 * @date 2024-06-19
 */
@RestController
@RequestMapping("/EamD")
public class EamManageDController extends BaseController
{
    @Autowired
    private IEamManageDService eamManageDService;

    /**
     * 查询资产记录从列表
     */
//    @RequiresPermissions("system:d:list")
    @GetMapping("/list")
    public TableDataInfo list(EamManageD eamManageD)
    {
        startPage();
        List<EamManageD> list = eamManageDService.selectEamManageDList(eamManageD);
        return getDataTable(list);
    }

    /**
     * 导出资产记录从列表
     */
    //@RequiresPermissions("system:d:export")
    @Log(title = "资产记录从", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EamManageD eamManageD)
    {
        List<EamManageD> list = eamManageDService.selectEamManageDList(eamManageD);
        ExcelUtil<EamManageD> util = new ExcelUtil<EamManageD>(EamManageD.class);
        util.exportExcel(response, list, "资产记录从数据");


    }

    /**
     * 获取资产记录从详细信息
     */
    //@RequiresPermissions("system:d:query")
    @GetMapping(value = "/{assetId}")
    public AjaxResult getInfo(@PathVariable("assetId") Long assetId)
    {
        return success(eamManageDService.selectEamManageDByAssetId(assetId));
    }

    /**
     * 新增资产记录从
     */
//    @RequiresPermissions("system:d:add")
//    @Log(title = "资产记录从", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EamManageD eamManageD)
    {

        return toAjax(eamManageDService.insertEamManageD(eamManageD));
    }

    /**
     * 修改资产记录从
     */
//    @RequiresPermissions("system:d:edit")
//    @Log(title = "资产记录从", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EamManageD eamManageD)
    {
        return toAjax(eamManageDService.updateEamManageD(eamManageD));
    }

    /**
     * 删除资产记录从
     */
//    @RequiresPermissions("system:d:remove")
//    @Log(title = "资产记录从", businessType = BusinessType.DELETE)
	@DeleteMapping("/{manageId}")
    public AjaxResult remove(@PathVariable String[] manageId)
    {
        return toAjax(eamManageDService.deleteEamManageDByAssetIds(manageId));
    }

    @GetMapping("/selectByMId/{manageId}")
    public EamManageD test(@PathVariable("manageId") String manageId){
        return eamManageDService.selectEamManageDByManageId(manageId);
    }

    @GetMapping(value = "/updDelEamD/{manageIds}")
    public AjaxResult updateDelEamD(@PathVariable String[] manageIds){
        return success(eamManageDService.updateDelEamD(manageIds));
    }
}
